import { observable, action, autorun, toJS } from 'mobx';
import * as  Apis from '../apis/govern';
import { WeaLocaleProvider, WeaTools } from 'ecCom';
import { message, Modal } from 'antd';
import { WeaForm } from 'comsMobx';
import _ from "lodash";
import WeaUtils from "../components/E9/dialog/wea-utils";
import { ListStore } from './listStore';
import { ModalConfirmStore } from './modalConfirmStore';
import { GovernShareStore } from './governShareStore';
import BtnType from '../util/btnType';
import { isHasKey } from '../util/index';
import GetFormJson from '../util/getFormJson';
const { GetRegex, DateFormat } = WeaUtils;
const getLabel = WeaLocaleProvider.getLabel;
var Base64 = ecCom.WeaTools.Base64;

/**
 * 督办理模块所有弹窗、确认框执行的动作接口
 */
export class ModelStore extends ListStore {
    @observable status = {
        title: "由后台或父组件传值",
    };

    @observable id = "";
    @observable ids = [];//批量处理时的id集合
    @observable modelType = "";
    @observable visible = false;//是否显示弹窗
    @observable percent = parseInt(0);//进度百分比
    @observable isFinishTask = false;//任务完结标志
    @observable isDiscard = false;//任务废弃标志
    @observable content = "";
    @observable rightMenu = {};//获取改变任务状态后右侧按钮组的数据
    @observable form = new WeaForm();//各个弹窗模式公共form表单
    @observable shareStore = new GovernShareStore();//添加共享时用的
    //加号
    @observable condition = [];
    @observable listStoreB = new ListStore(); //分解用  加载每个子任务的data
    @observable listStoreB1 = {}; //分解用  用于添加新明细任务
    @observable visibleTip = false;
    suffix = 0;//分解用当前明细index
    deleteIds = "";//分解用 已经删除的任务id
    defalutValues = {};//分解用 当model加载之后 把初始值缓存下来 用于提交时校验是否改变
    perDelCondition = [];//分解用 删除子任务前对任务保存
    @observable confirmVisible = false;//不需要弹窗的按钮  通过此参数控制提示框是否显示
    @observable modalConfirmStore = new ModalConfirmStore();//提示框store 提示框的方法在这个store里执行
    @observable memoryValue = '';//存储Value
    @observable richTextValue = '';
    @observable richTextShowType = '0';

    uploadProjectRefs; // 存储事项的refs
    uploadTaskRefs; // 存储任务的refs
    @observable uploadSize = []; //上傳個數
    @observable submitFlag = false; //上传标识，提交的时候true
    @observable changeFlag = false;
    @observable uploadRefSize = 0; //上傳組件個數
    @observable cubeLayoutParame = {};//装载布局请求入参
    @observable Card = {};
    card = {};
    taskid;
    routepath;
    deletclose = false;

    arrayValid = [];
    filedsize = 0;
    specialField = {};//特殊字段
    @observable loading = true;
    @observable startdate = '';
    @observable enddate = '';
    @observable isopenModal = false;
    @observable formBCellLength = 0;
    @observable delIndex = 0;//删的是第几个子任务
    @observable dodel = false;
    @observable astartdate = '';
    @observable aenddate = '';

    constructor(props) {
        super(props);
        this.setSlider = this.setSlider.bind(this)
        this.subBtn = this.subBtn.bind(this)
        this.initModel = this.initModel.bind(this)
        this.changeRichText = this.changeRichText.bind(this)
        this.btnAddClick = this.btnAddClick.bind(this)
        this.btnMouseLeave = this.btnMouseLeave.bind(this)
        this.btnDelClick = this.btnDelClick.bind(this)
        this.finishTask = this.finishTask.bind(this)
        this.getNewRightMenu = this.getNewRightMenu.bind(this, props)
    }

    @observable btnvisible = true;

    @action
    showSpaModel = (id, modelType) => {
        this.id = id;
        this.modelType = modelType;
        this.visible = true;
        this.btnvisible = false;
        this.form = new WeaForm();
        this.initModel(modelType, id);
    }

    //存储事项的refs
    @action
    getuploadProjectRef(dom) {
        // console.log("dom", dom)
        this.uploadProjectRefs = dom;
        // for (let ref in this.uploadProjectRefs) {
        //     console.log("refs12", ref);
        // }
    }

    @action
    getuploadTaskRef(dom) {
        this.uploadTaskRefs = dom;
        // for (let ref in this.uploadTaskRefs) {
        //     console.log("refs", ref);
        // }
    }

    //执行事项的上传
    @action
    doProUpload = () => {
        for (let ref in this.uploadProjectRefs) {
            this.uploadProjectRefs[ref].doUpload();
        }
    }

    @action
    doTaskUpload = () => {
        for (let ref in this.uploadTaskRefs) {
            this.uploadTaskRefs[ref].doUpload();
        }
    }

    @action
    updateForm = (listT, listB, upload, form, field, uploadSize) => {
        // console.log("kus", listT, listB, form.getFormParams(), this.submitFlag)
        if (listB && listB.length == 0 && listT && listT.length == 0 && !this.submitFlag) {
            upload[field.domkey] = "";
            form.updateFields(upload); //赋值绕过检验规则
            // console.log("form", form.getFormParams());
        }
        if (listT && listT.length > 0 && this.submitFlag && listB && listB.length == 0) {
            let imagefileids = [];
            listT.map((item, index) => {
                imagefileids.push(item.fileid);
            })
            upload[field.domkey] = imagefileids.join(",");
            form.updateFields(upload);

            uploadSize = uploadSize.push("1"); //注意并发
            // console.log("from", form.getFormParams());
            let uploadsize = this.uploadRefSize;
            if (uploadSize == uploadsize) {
                if (this.changeFlag) {
                    this.saveChangeTask();
                } else {
                    this.saveDecomposeTask();
                }
            }
        }
        //無文件保存
        if (listB && listB.length == 0 && listT && listT.length == 0 && this.submitFlag) {
            uploadSize = uploadSize.push("1"); //注意并发
            let uploadsize = this.uploadRefSize;
            if (uploadSize == uploadsize) {
                if (this.changeFlag) {
                    this.saveChangeTask();
                } else {
                    this.saveDecomposeTask();
                }
            }
        }
    }



    /**
     * 加载确认框
     */
    initConfirm = (id, modelType) => {
        this.id = id;
        this.modelType = modelType;
    }


    /**
     * 展示弹窗方法
     */
    showConfirm = (param) => {
        let _this = this;
        Modal.confirm({
            cancelText: `${getLabel(201, '取消')}`,
            okText: `${getLabel(826, '确定')}`,
            title: typeof param.title === "function" ? param.title() : param.title,
            content: typeof param.content === "function" ? param.content() : param.content,
            onOk() {
                _this.subBtn(param.modelType, param.id);
            },
            onCancel() { },
        });
    }

    /**
     * 展示弹窗方法  用户列表批量操作
     */
    showConfirmBatch = (param) => {
        let _this = this;
        Modal.confirm({
            cancelText: `${getLabel(201, '取消')}`,
            okText: `${getLabel(826, '确定')}`,
            title: param.title,
            content: param.content,
            onOk() {
                _this.subBtn(param.modelType, param.id);
                if (typeof (param.callBack === "function")) {
                    param.callBack();
                }
            },
            onCancel() { },
        });
    }

    /**
     * 富文本工具栏组件信息
     */
    bottomConfigData = {
        "appList": [
            {
                "items": [
                    "Document",
                    "Schedule",
                    "Flow"
                ],
                "name": "dialogs"
            },
            {
                "items": [
                    {
                        "Attachment": {
                            "uploadUrl": "/api/doc/upload/uploadFile?model=reply",
                            "position": "/api/doc/upload/uploadFile?model=reply",
                            "maxSize": "256"
                        }
                    }
                ],
                "name": "uploads"
            }
        ],
        "status": "1"
    };

    //富文本 默认工具栏配置
    basicToolBar = {
        toolbar: [
            { name: 'document', items: ['Source'] },
            { name: 'paragraph', items: ['JustifyLeft', 'JustifyCenter', 'JustifyRight', '-', 'NumberedList', 'BulletedList'] },
            { name: 'styles', items: ['Format', 'Font', 'FontSize'] },
            { name: 'colors', items: ['TextColor'] },
            { name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike',] },
            { name: 'insert', items: ['Image', 'Table', 'Smiley'] },
            { name: 'tools', items: ['Maximize'] }
        ],
    };

    /**
     * 切换model显示方法
     */
    @action
    handleShareDialog = (bool, type, id, params = {}) => {
        if (!bool) {
            this.cleanData();
        }
        this.visible = bool;
        this.btnvisible = true;
    }

    //加号
    @action
    getdomkeyList() {
        let domkeyList = [];
        let everyDomkeyList = [];
        this.listStoreB["condition"].map((c) => {
            c.items.map((i) => {
                let domkeyitemList = [];
                i.domkey.map((d) => {
                    domkeyitemList.push(d);
                });
                domkeyList = domkeyList.concat(domkeyitemList);
            });
        });
        this.listStoreB["condition"][0].items.map((i) => {
            let domkeyitemList = [];
            i.domkey.map((d) => {
                domkeyitemList.push(d);
            });
            everyDomkeyList = everyDomkeyList.concat(domkeyitemList);
        });
        domkeyList = _.flattenDeep(domkeyList);
        everyDomkeyList = _.flattenDeep(everyDomkeyList);
        return { domkeyList, everyDomkeyList };
    }

    /*******************************************************任务分解***************************************************************************** */
    /**
     * 分解
     * 添加行方法
     * @param {*} index
     */
    @action
    btnAddClick(index) {
        this.visibleTip = false;
        this.suffix++
        let sourceData = {};
        sourceData = _.cloneDeep(toJS(this.listStoreB1["condition"][0]));
        sourceData.items.map((i) => {
            let newDomkey = [];
            i.domkey.map((d) => {
                d = `${d}_${this.suffix}`;
                newDomkey.push(d);
            });
            i.domkey.length = 0;
            i.domkey = [...newDomkey];
        });
        this.listStoreB["condition"].splice((index + 1), 0, sourceData);
        /*this.listStoreB["condition"].map((c,index)=>{
            c.title = (index+1).toString();
        });*/
        sourceData.items.map((i, index) => {
            this.formB.initFormFieldObj([i]);
        });
    }

    /**
     * 分解
     * 删除行方法
     * @param {*} index
     */
    @action
    btnDelClick(index) {
        this.delIndex = index;
        this.dodel = true;
        this.visibleTip = false;
        this.listStoreB["condition"].splice(index, 1);
        const formValues = this.formB.getFormDatas();
        this.formB = new WeaForm();
        this.formB.initFormFields(toJS(this.listStoreB.condition));
        this.formB.updateFields(formValues);
        let len = this.listStoreB["condition"].length;
        let id = this.perDelCondition[index];//保存删除的子任务id
        if (id) {
            this.deleteIds += ("," + id);
        }
    }

    /**
     * 分解
     * 删除最后一个的提示方法
     * @param {*} index
     */
    @action
    btnMouseLeave(index) {
        let len = this.listStoreB["condition"].length
        if (len <= 1) {
            setTimeout(() => { this.visibleTip = false }, 100)
        }
    }

    /**
     * 分解
     * 获取默认空明细
     * @param {*} condition
     */
    getDefaultSearchDate(condition) {
        if (condition && condition.length > 0) {
            let sourceData = condition[0];
            sourceData.items = sourceData.items || [];
            sourceData.items.map((i) => {
                let newDomkey = [];
                i.domkey.map((d) => {
                    d = `${d}_${this.suffix}`;
                    newDomkey.push(d);
                });
                i.domkey.length = 0;
                i.domkey = [...newDomkey];
            });
            return sourceData;
        }
    }

    /**
     * 分解
     * 把当前页面默认的属性记录一下 保存的时候只保存改变的内容
     * @param {*} conditions
     */
    getdefaultValues(conditions) {
        conditions.map((sourceData) => {
            const { id } = sourceData;
            let data = {};
            sourceData.items.map((i) => {
                let fieldname = i.domkey[0];
                let _value = i.value;
                let fa = fieldname.split("_");
                let _fieldname = fa[0];
                data[_fieldname] = _value
            })
            this.defalutValues[id] = data;
        })
    }

    /**
     * 分解
     * 解析子任务数据
     * @param {*} formValue
     */
    getDecomposeData(formValue) {
        let taskData = [];
        for (let i = 0; i < this.listStoreB.condition.length; i++) {
            let sourceData = this.listStoreB.condition[i];
            let data = {};
            let changed = 0;

            let defalutValues = this.defalutValues[sourceData.id] || {};
            sourceData.items.map((i) => {
                let fieldname = i.domkey[0];//获取字段名
                let value = formValue[fieldname] || "";//获取表单中的字段值
                let fa = fieldname.split("_");
                let _fieldname = fa[0];
                let _value = defalutValues[_fieldname] || "";//获取初始值
                if (sourceData.id) {
                    if (value != _value) {//如果发生改变才处理
                        data[_fieldname] = value;
                        changed = 1;
                    }
                } else {
                    data[_fieldname] = value;
                }
            });
            taskData.push({
                id: sourceData.id || "0",
                status: sourceData.status || "0",
                index: i,
                data: data,
                changed: changed
            })
        }
        return taskData;
    }

    /**
     * 分解加载历史数据及明细内容方法
     * @param {*} newParems
     */
    @action
    getDecomposeTaskLayout() {
        this.condition = [];
        this.form.resetForm();
        this.formB = new WeaForm();
        this.deleteIds = "";
        this.defalutValues = {};
        this.loading = true;
        this.cubeLayoutParame = {};
        let _this = this;
        _this.formBCellLength = 0;
        _this.delIndex = 0;
        _this.dodel = false;
        Apis.getDecomposeTaskLayout({ id: this.id }).then(data => {
            if (parseInt(data.status) == 1) {
                _this.mackCondition(data);
                if (data.isopen === true) {
                    _this.cubeLayoutParame = data.data;
                }
            } else {
                message.error(data.error);
            }
            let fromDataB = _.mapKeys(_.pick(data, ['condition2']), (value, key) => key.slice(0, -1));//处理添加内容
            fromDataB = GetFormJson.setFormJson(fromDataB, _this.form, "condition", ["name", "remark"], [1, 2], [4, 9], [18, 15], _this.getCondition, _this, false);
            let mouldData = _.pick(data, ['conditions']);//渲染模板数据,只在初始化用一次
            mouldData = GetFormJson.setFormJson(mouldData, _this.form, "conditions", ["name", "remark"], [1, 2], [4, 9], [18, 15], _this.getCondition, _this, false);
            let conditions = mouldData.conditions || [];//加载之前已经添加的子任务
            if (conditions.length == 0) {
                conditions.push(_this.getDefaultSearchDate(_.cloneDeep(toJS(fromDataB["condition"]))));  //如果没有添加过子任务  默认添加空明细
            } else {
                _this.getdefaultValues(conditions);
            }
            _this.suffix = conditions.length - 1;//添加明细时用的下标
            _this.listStoreB.condition = [].concat(conditions);
            _this.perDelCondition = _.cloneDeep(_this.listStoreB.condition);
            _this.listStoreB1 = fromDataB;
            if (_this.formB) {
                _this.formB.initFormFields(data.conditions);
            }
            if (data.condition2 && data.condition2[0].items) {
                _this.formBCellLength = data.condition2[0].items.length;
            }
            _this.loading = false;
        }).catch(error => {
            message.error(error);
        });

    }
    /**
     * 变更方法
     * @param {*} newParems
     */
    @action
    getChangeTaskLayout(id) {
        this.form.resetForm();
        this.formB.resetForm();
        this.loading = true;
        this.cubeLayoutParame = {};
        let _this = this;
        Apis.getChangeTaskLayout({ id: id }).then(data => {
            //接口返回正确的数据
            if (parseInt(data.status) == 1) {
                if (data.isopen === true) {
                    _this.cubeLayoutParame = { ...data.data };
                }
                // if (isHasKey(data, "condition1", "items")) {#806199 概述：解决督办任务描述字段勾选为必填，变更页面，任务描述内容乱码的问题
                //     data.condition1[0].items.map((i) => {
                //         if (i.domkey[0] == "remark" && _.has(i, 'value') && i.viewAttr == 3) {
                //             i.value = Base64.decode(i.value);
                //         }
                //     })
                // }
                if (parseInt(data.status) == 1) {
                    GetFormJson.setFormJson(data, _this.form, "condition1", ["name", "remark"], [1, 2], [4, 9], [18, 15], _this.getCondition, _this, true);
                } else {
                    message.error(data.error);
                }
            } else {
                message.error(data.error);
            }
            this.loading = false;
        }).catch(error => {
            message.error(error);
        })
    }
    @action
    mackCondition(data) {
        let _this = this;
        let _data = _.cloneDeep(data);
        let _data1 = _.has(_data, 'condition1') ? _.pick(_data, ['condition1']) : [];
        GetFormJson.setFormJson(_data1, _this.form, "condition1", ["name", "remark"], [1, 2], [4, 9], [20, 15], _this.getCondition, _this, true);//渲染顶部区域
    }
    @action
    getCondition(condition, _this) {
        _this.condition = condition;
    }
    /*******************************************************任务分解***************************************************************************** */

    @action
    showShare = (id, ids) => {
        this.id = id;
        this.ids = ids;
        this.shareStore.onShowAdd(true);
    }

    /**
     * 初始化各个类型的动作页面
     * @param {*} modelType
     * @param {*} id
     */
    @action
    initModel(modelType, id) {

        this.id = id;
        this.content = "";
        if (modelType == BtnType.BTN_REPORT || modelType == BtnType.BTN_URGENT || modelType == BtnType.BTN_CREATE) {
            this.memoryValue = "";
            this.richTextShowType = "0";
        }
        this.percent = parseInt(0);
        this.modelType = modelType;
        if (modelType == "issplitLevel" || modelType == BtnType.BTN_SPLIT) {//分解
            this.getDecomposeTaskLayout();
        } else if (modelType == "ischangeLevel" || modelType == BtnType.BTN_CHANGE) {//督办变更
            this.getChangeTaskLayout(id);
        } else if (modelType == "isreportLevel" || modelType == "isdisLevel" || modelType === "remindTask" || modelType == BtnType.BTN_REPORT || modelType == BtnType.BTN_URGENT || modelType == BtnType.BTN_INSTRUCT) {
            this.form.resetForm();
            this.formB.resetForm();
            this.loading = true;

            Apis.getTaskInfo({ id: id, modelType: modelType }).then(data => {
                if (parseInt(data.status) == 1) {
                    if (data.isopen === true) {
                        this.cubeLayoutParame = data.data;
                    } else {
                        this.cubeLayoutParame = {};
                    }
                    if (modelType == "isreportLevel" || modelType == BtnType.BTN_REPORT) {
                        this.percent = parseInt(data.progress);
                    }
                    let snapData = {
                        "searchCondition": [
                            {
                                "title": "",
                                "items": [
                                    {
                                        "colSpan": 1,
                                        "conditionType": "INPUT",
                                        "rules": "required",
                                        "domkey": [
                                            "topic"
                                        ],
                                        "labelcol": 4,
                                        "fieldcol": 20,
                                        "isQuickSearch": true,
                                        "label": `${getLabel(344, '主题')}`,
                                        "viewAttr": 1,
                                        "value": data.title,
                                    }
                                ],
                                "defaultshow": true
                            }
                        ]
                    };
                    this.richTextShowType = "0";
                    data = _.cloneDeep(snapData);
                    this.condition = data.searchCondition;
                    this.form && !this.form.isFormInit && this.form.initFormFields(data.searchCondition);
                } else {
                    message.error(data.error);
                }
                this.loading = false;
            }).catch(error => {
                message.error(error);
            });
        } else if (modelType == BtnType.BTN_SHOWREPORT || modelType == BtnType.BTN_SHOWINSTRUCT || modelType == BtnType.BTN_SHOWURGENT || modelType == BtnType.BTN_EDIT) {
            this.form = new WeaForm();
            this.formB.resetForm();
            this.loading = true;
            Apis.getRichTextInfo({ id: id, modelType: modelType }).then(action(data => {
                if (data.isopen === true) {
                    this.cubeLayoutParame = data.data;
                } else {
                    this.cubeLayoutParame = {};
                }
                this.memoryValue = data.content;
                this.loading = false
            }))
            this.richTextShowType = "1";
            if (modelType == BtnType.BTN_EDIT) {
                this.richTextShowType = "0";
            }
            this.condition = [];
            this.form && !this.form.isFormInit && this.form.initFormFields([]);
        }else if(modelType == BtnType.BTN_SHOWULOGCHANGE){
            Apis.getRichTextInfo({ id: id, modelType: modelType }).then(action(data => {
                if(parseInt(data.status) == 1){
                    if (data.isopen === true) {
                        this.cubeLayoutParame = data.data;
                    } else {
                        this.cubeLayoutParame = {};
                    }
                    this.tableStoreLog.getDatas(data.sessionkey, 1);
                  }else{
                    message.error(data.error);
                  }
                this.loading = false
            }))
        }
    }

    /**
     * 富文本改变事件
     * @param {*} v
     */
    @action
    changeRichText(content) {
        this.content = content;
    }
    /*
    *汇报进度条进度
    */
    @action
    setSlider(v) {
        this.percent = v;
    }

    /*************************************************************提交时接口处理逻辑end******************************************************************** */

    //汇报
    @action
    reportTask(id, selfparams) {
        const comparams = { ...{ progress: this.percent }, ...{ content: this.content }, ...{ taskid: id } };
        let params1 = { ...this.form.getFormParams(), ...comparams };
        let params2 = { ...selfparams, taskid: id }
        const params = Object.keys(this.card).length > 0 ? params2 : params1;
        this.reportTaskAjax(params);
    }
    reportTaskAjax = (params) => {
        Apis.reportTask(params).then(data => {
            if (data.status == 1) {
                message.success(`${getLabel('16248', '提交成功！')}`);
            } else if (data.status == -1) {
                message.warning(data.error)
            } else if (data.status == -3) {
                message.warning(data.error)
                this.handleShareDialog(true);
                return;
            } else {
                message.error(data.error)
            }
            // _this.init({ "taskId": id, "pageindex": 1, "pagesize": 10 });xk:暂时去掉不知道有什么用
        }).catch(error => {
            this.memoryValue = this.content;
            message.warning(getLabel('501166', "输入内容过多了"));
            this.handleShareDialog(true);
            return;
        });
        this.handleShareDialog(false);
    }

    //初始化
    @action
    init = (params) => {
        Apis.getInstructList(params).then(data => {
            let result = [
                {
                    "appList": [
                        {
                            "items": [
                                "Document",
                                "Schedule",
                                "Flow"
                                /* "Task",
                                "Templet" */
                            ],
                            "name": "dialogs"
                        },
                        {
                            "items": [
                                {
                                    "Attachment": {
                                        "uploadUrl": "/api/doc/upload/uploadFile?model=reply",
                                        "position": "/api/doc/upload/uploadFile?model=reply",
                                        "maxSize": "256"
                                    }
                                }
                            ],
                            "name": "uploads"
                        }
                    ],
                    "status": "1"
                }
            ];
            if (parseInt(data.status) == 1) {
                result = result.concat(data);
                //解码评论内容
                let copyresult1 = { ...result[1] };
                copyresult1.discussList && copyresult1.discussList.forEach((record, index) => {
                    if (record.content) {
                        let decodeContent = Base64.decode(record.content);
                        result[1].discussList[index] = {
                            ...record,
                            content: decodeContent
                        };
                    }
                    if (record.instructReplyList && record.instructReplyList.length > 0) {
                        record.instructReplyList.forEach((_record, _index) => {
                            let decodeContentReply = Base64.decode(_record.content);
                            result[1].discussList[index].instructReplyList[_index] = {
                                ..._record,
                                content: decodeContentReply
                            };
                        });
                    }
                });
                this.status = {
                    ...this.status,
                    weiboCKEditorConfig: result[0],
                    weiboList: result[1],
                    loading: false
                };
            } else {
                message.error(data.error);
            }
        }).catch(error => {
            message.error(error);
        });
    };
    //分解
    @action
    decomposeTask(id, routepath) {
        this.submitFlag = true;
        this.taskid = id;
        let uploadTaskRefSize = 0;

        if (this.uploadTaskRefs != null) {
            uploadTaskRefSize = Object.keys(this.uploadTaskRefs).length;
        }

        this.uploadRefSize = uploadTaskRefSize;
        if (uploadTaskRefSize > 0) {
            this.doTaskUpload();
        }
        if (uploadTaskRefSize == 0) { //没有上传组件的时候直接保存任务
            this.saveDecomposeTask();
        }

    }

    saveDecomposeTask = () => {
        // console.time("测试 fn 速度: ")
        // let params = { ...this.form.getFormParams(), ...{ progress: this.percent }, ...{ content: this.content }, ...{ taskid: this.taskid } };
        this.validDateHandle();
        if (this.isopenModal) {
            this.cleanData();
            return false;
        }
        if (!this.isopenModal) {
            this.checkValidate().then(data => {
                let validateFormResult = this.arrayValid.every((a) => {
                    return a === true;
                })
                let taskData = this.getDecomposeData({ ...this.formB.getFormParams() });
                let _this = this;
                const comparams = { ...{ progress: this.percent }, ...{ content: this.content }, ...{ taskid: this.taskid }, ...{ deleteIds: _this.deleteIds } };
                let params1 = { ...this.form.getFormParams(), ...comparams, ...{ taskData: JSON.stringify(taskData) }, "routepath": this.routepath };
                let params2 = { taskid: this.taskid, "routepath": this.routepath }
                const params = Object.keys(this.card).length > 0 ? params2 : params1;
                if (Object.keys(this.card).length === 0) {
                    if (validateFormResult === true) {
                        // Apis.decomposeTask({ taskData: JSON.stringify(taskData), deleteIds: _this.deleteIds, ...params }).then(data => {
                        //     if (parseInt(data.status) == 1) {
                        //         message.success(`${getLabel('16248', '提交成功！')}`);
                        //         if (typeof (this.routepath) === "string") {//lusx 19.3.1 #554330 督办，督办台账，督办变更，提交后，页面不应刷新成首次登陆的页面
                        //             // this.routepath.length > 0 ?null: window.location.reload();
                        //             if (this.routepath.length > 0) {
                        //                 null
                        //             } else {
                        //                 window.location.reload();
                        //             }
                        //         }
                        //     } else {
                        //         message.error(data.error);
                        //     }
                        //     _this.cleanData();
                        //     _this.handleShareDialog(false);
                        // }).catch(error => {
                        //     message.error(error);
                        // });
                        this.decomposeTaskHandle(params);
                    } else {
                        _this.formB.validateForm().then(f => {
                            if (!f.isValid) {
                                f.showErrors();
                            }
                        });
                        //_this.formB.validate({ showErrors: true });
                        _this.cleanData();
                        _this.handleShareDialog(true);
                    }
                } else {
                    this.decomposeTaskHandle(params);
                }
            });
        }
    }

    decomposeTaskHandle = (params) => {
        let _this = this;
        Apis.decomposeTask(params).then(data => {
            if (parseInt(data.status) == 1) {
                message.success(`${getLabel('16248', '提交成功！')}`);
                if (typeof (params.routepath) === "string") {//lusx 19.3.1 #554330 督办，督办台账，督办变更，提交后，页面不应刷新成首次登陆的页面
                    // this.routepath.length > 0 ?null: window.location.reload();
                    if (params.routepath.length > 0) {
                        null
                    } else {
                        window.location.reload();
                    }
                }
            } else {
                message.error(data.error);
            }
            _this.cleanData();
            _this.handleShareDialog(false);
        }).catch(error => {
            message.error(error);
        });
    }


    cleanData = () => {
        this.uploadTaskRefs = {};
        this.uploadProjectRefs = {};
        this.uploadSize = [];
        this.submitFlag = false;
        this.uploadRefSize = 0;
        this.changeFlag = false;
        this.arrayValid = [];
        this.filedsize = 0;
    }

    //批量下发
    @action
    distributeAll(id) {
        Apis.distributeAll({ taskid: id }).then(data => {
            if (parseInt(data.status) == 1) {
                message.success(`${getLabel('16634,84565', '确认成功！')}`);
            } else {
                message.error(data.error);
            }
        }).catch(error => {
            message.error(error);
        });
    }
    //下发
    @action
    distribute(id) {
        Apis.distribute({ taskid: id }).then(data => {
            if (parseInt(data.status) == 1) {
                message.success(`${getLabel('387965,84565', '下发成功！')}`);
                window.location.reload();
            } else {
                message.error(data.error);
            }
        }).catch(error => {
            message.error(error);
        });
    }
    //变更
    @action
    changeTask(id, routepath) {
        this.submitFlag = true;
        this.taskid = id;
        this.changeFlag = true;
        let uploadProRefSize = Object.keys(this.uploadProjectRefs).length; //获取上传组件个数
        this.uploadRefSize = uploadProRefSize
        if (uploadProRefSize > 0) { //事项里有上传组件执行上传，在回调函数里保存事项
            this.doProUpload();
        }
        if (uploadProRefSize == 0) { //没有上传组件的时候直接保存任务
            this.saveChangeTask();
        }
    }
    @action
    validDateHandleErr1 = () => {
        message.error(`${getLabel('511480', '开始日期时间不能大于结束日期时间')}`);
        this.validDateHandleCom();
    }
    // @action
    // validDateHandleErr2=()=>{
    //     message.error(`${getLabel('511481', '结束日期时间不能小于当前日期时间')}`);
    //     this.validDateHandleCom();
    // }
    @action
    validDateHandleCom = () => {
        this.handleShareDialog(true);
        this.isopenModal = true;
        return false;
    }
    @action
    validDateHandlePro = (startdatekey = '', starttimekey = '', enddatekey = '', endtimekey = '') => {
        if (this.form.has(startdatekey) && this.form.has(enddatekey)) {
            let startdate = this.form.has(starttimekey) ? this.form.$(startdatekey).value.concat(" ", this.form.$(starttimekey).value).replace(/-/g, '/') : this.form.$(startdatekey).value.concat(" ", "00:00"),
                enddate = this.form.has(endtimekey) ? this.form.$(enddatekey).value.concat(" ", this.form.$(endtimekey).value).replace(/-/g, '/') : this.form.$(enddatekey).value.concat(" ", "00:00");
            if (startdate !== '' && enddate !== '' && new Date(startdate) > new Date(enddate)) {
                this.validDateHandleErr1();
            }
            // if(new Date(enddate) < new Date(new Date())){
            //     this.validDateHandleErr2();
            // }
        }
    }
    @action
    validDateHandleTask1 = (startdate = '', enddate = '') => {
        if (startdate !== '' && enddate !== '' && new Date(startdate) > new Date(enddate)) {
            this.validDateHandleErr1();
        }
        // if(new Date(enddate) < new Date() ) {
        //     this.validDateHandleErr2();
        // }
    }
    validDateHandleTaskStr = (key = '', fieldkey) => (fieldkey.replace(/\s*/g, "").replace(/\"/g, "").toString()).startsWith(key)
    /**
     * 开始日期不能大于结束日期
     */
    @action
    validDateHandle() {
        this.startdate = '';
        this.enddate = '';
        this.astartdate = '';
        this.aenddate = '';
        this.isopenModal = false;
        this.validDateHandlePro('startdate', 'starttime', 'enddate', 'endtime');
        this.validDateHandlePro('astartdate', 'astarttime', 'aenddate', 'aendtime');
        if (this.formB) {
            const _this = this;
            _this.formB.map((field, index) => {
                if (this.validDateHandleTaskStr('startdate', field.key)) {
                    _this.startdate = field.values().concat(" ", "00:00")
                } else if (this.validDateHandleTaskStr('enddate', field.key)) {
                    _this.enddate = field.values().concat(" ", "00:00")
                } else if (this.validDateHandleTaskStr('starttime', field.key)) {
                    const starttime = field.values();
                    _this.startdate = _this.startdate.split(" ")[0].concat(" ", starttime).replace(/-/g, '/');
                } else if (this.validDateHandleTaskStr('endtime', field.key)) {
                    const endtime = field.values();
                    _this.enddate = _this.enddate.split(" ")[0].concat(" ", endtime).replace(/-/g, '/');
                } else if (this.validDateHandleTaskStr('astartdate', field.key)) {
                    _this.astartdate = field.values().concat(" ", "00:00")
                } else if (this.validDateHandleTaskStr('aenddate', field.key)) {
                    _this.aenddate = field.values().concat(" ", "00:00")
                } else if (this.validDateHandleTaskStr('astarttime', field.key)) {
                    const starttime = field.values();
                    _this.astartdate = _this.astartdate.split(" ")[0].concat(" ", starttime).replace(/-/g, '/');
                } else if (this.validDateHandleTaskStr('aendtime', field.key)) {
                    const endtime = field.values();
                    _this.aenddate = _this.aenddate.split(" ")[0].concat(" ", endtime).replace(/-/g, '/');
                }
                if (index != 0 && index % (_this.formBCellLength - 1) == 0) {
                    //    const goon = (_this.dodel === true) ? ((_this.delIndex+1) != index/(_this.formBCellLength-1) ? true : false) : true;
                    const goon = true;
                    if (goon) {
                        _this.validDateHandleTask1(_this.startdate, _this.enddate);
                        _this.validDateHandleTask1(_this.astartdate, _this.aenddate);
                    }
                    _this.startdate = '';
                    _this.enddate = '';
                    _this.astartdate = '';
                    _this.aenddate = '';
                }
            })
        }
    }
    saveChangeTask = () => {
        let _this = this;
        this.validDateHandle();
        // let params = { ...this.form.getFormParams(), ...{ progress: this.percent }, ...{ content: this.content }, ...{ taskid: this.taskid } };
        let comparams = { ...{ progress: this.percent }, ...{ content: this.content }, ...{ taskid: _this.taskid } };
        let params1 = { ...this.form.getFormParams(), ...comparams, "routepath": this.routepath };
        let params2 = { taskid: _this.taskid, "routepath": this.routepath };
        const params = Object.keys(this.card).length > 0 ? params2 : params1;
        _this.cutoffTime(params);

        if (this.isopenModal) {
            _this.cleanData();
            return false;
        }
        if (!this.isopenModal) {
            this.form.validateForm().then(_data => {
                if (_data.isValid) {
                    this.changeTaskAjax(params);
                } else {
                    _data.showErrors();
                    _this.cleanData();
                    _this.handleShareDialog(true);
                }
            })
        }
    }

    changeTaskAjax = (params) => {
        let _this = this;
        this.loading = true;
        Apis.changeTask(params).then(data => {
            if (parseInt(data.status) == 1) {
                message.success(`${getLabel('16248', '提交成功！')}`);
                _this.loading = false;
                if (typeof (params.routepath) === "string") {//lusx 19.3.1 #554330 督办，督办台账，督办变更，提交后，页面不应刷新成首次登陆的页面
                    // this.routepath.length > 0 ?null: window.location.reload();
                    if (params.routepath.length > 0) {
                        null
                    } else {
                        window.location.reload();
                    }
                }
            } else {
                message.error(data.error);
            }
            _this.cleanData();
            _this.handleShareDialog(false);
        }).catch(error => {
            message.error(error);
        });
    }

    //催办
    @action
    remindTask(id, selfparams) {
        this.memoryValue = "";
        // let params = { ...this.form.getFormParams(), ...{ progress: this.percent }, ...{ content: this.content }, ...{ taskid: id } };
        let comparams = { ...{ progress: this.percent }, ...{ content: this.content }, ...{ taskid: id } };
        let params1 = { ...this.form.getFormParams(), ...comparams };
        let params2 = { ...selfparams, taskid: id };
        const params = Object.keys(this.card).length > 0 ? params2 : params1;
        this.remindTaskAjax(params)
    }
    remindTaskAjax = (params) => {
        Apis.remindTask(params).then(data => {
            if (parseInt(data.status) == 1) {
                message.success(`${getLabel('16248', '提交成功！')}`);
            } else if (data.status == -1) {
                message.warning(data.error)
            } else if (data.status == -3) {
                message.warning(data.error)
                this.handleShareDialog(true);
                return;
            } else {
                message.error(data.error);
            }
        }).catch(error => {
            this.memoryValue = this.content;
            message.warning(getLabel('501166', "输入内容过多了"));
            this.handleShareDialog(true);
            return;
        });
        this.handleShareDialog(false);
    }
    //发文预览
    @action
    docPreview(params) {
        this.id = params.id;
        this.modelType = BtnType.BTN_DOCVIEW;
        this.loading = true;
        Apis.docPreview(params).then(data => {
            if (parseInt(data.status) == 1 || data.status == true) {
                window.open(data.url);
            } else if (data.status == -2) {
                message.warning(data.error);
            } else {
                message.error(data.error);
            }
            this.loading = false;
        }).catch(error => {
            message.error(error);
        });
    }

    cubeLatoutSubmit = (params2, callBack) => {
        //const { Card } = (window.weaCube && window.weaCube.store) || {};
        const { ecmeDoSubmit } = this.Card.Actions;
        ecmeDoSubmit().then((data) => {
            if (callBack && typeof callBack === "function") {
                const params = Object.keys(this.card).length > 0 ? params2 : _.omit(params2, ['selfparams']);
                let resultJson = data.JSONStr;
                let governMainTable = {};
                for (let key in resultJson.mainTable) {
                    governMainTable = Object.assign(governMainTable, resultJson.mainTable[key]);
                }

                let mainTableJsonStr = { 'mainTable': Object.assign(governMainTable, this.specialField) }//xk:替换特殊字段值
                let newJsonStr = Object.assign(resultJson, mainTableJsonStr)

                //console.log("newJsonStr",newJsonStr);
                data.JSONStr = JSON.stringify(newJsonStr);
                this.specialField = {};
                callBack({ ...params, ...data });
            }
        })
    }

    @action
    subBtn(modelType, id, routepath, selfparams) {
        switch (modelType) {
            case "isreportLevel":
                this.reportTask(id)
                break;
            case BtnType.BTN_REPORT://汇报
                if (Object.keys(this.cubeLayoutParame).length > 0) {//建模布局保存方法
                    this.cubeLatoutSubmit({ "taskid": id, "selfparams": selfparams }, this.reportTaskAjax)
                } else {
                    this.reportTask(id, selfparams)
                }
                break;
            case BtnType.BTN_SPLIT://分解
                this.routepath = routepath;
                if (Object.keys(this.cubeLayoutParame).length > 0) {//建模布局保存方法
                    this.cubeLatoutSubmit({ "taskid": id, "routepath": this.routepath, "selfparams": selfparams }, this.decomposeTaskHandle)
                } else {
                    this.decomposeTask(id, routepath)
                }
                break;
            case "isdisLevel"://下发
                this.distributeAll(id)
                break;
            case "ischangeLevel":
                this.routepath = routepath;
                this.changeTask(id, routepath)
                break;
            case BtnType.BTN_CHANGE://变更
                this.routepath = routepath;
                if (Object.keys(this.cubeLayoutParame).length > 0) {//建模布局保存方法
                    this.cubeLatoutSubmit({ "taskid": id, "routepath": this.routepath, "selfparams": selfparams }, this.changeTaskAjax)
                } else {
                    this.changeTask(id, routepath)
                }
                break;
            case "remindTask":
                this.remindTask(id)
                break;
            case BtnType.BTN_URGENT://催办
                if (Object.keys(this.cubeLayoutParame).length > 0) {//建模布局保存方法
                    this.cubeLatoutSubmit({ "taskid": id, "selfparams": selfparams }, this.remindTaskAjax)
                } else {
                    this.remindTask(id, selfparams)
                }
                break;
            case BtnType.BTN_HAIR://下发
                this.distribute(id)
                break;
            case BtnType.BTN_FINISH://完结
                this.finishTask(id)
                break;
            case BtnType.BTN_BATCHHAIR://批量下发
                this.distributeAll(id)
                break;
            case BtnType.BTN_RECEIVE://签收
                this.signingTask(id)
                break;
            case BtnType.BTN_ATTENTION://关注
                this.attentTask(id)
                break;
            case BtnType.BTN_DISATTENTION://取消关注
                this.disAttentTask(id)
                break;
            case BtnType.BTN_DISCARD://废弃
                this.cancelTask(id)
                break;
            case BtnType.BTN_DISCARDBATCH://批量废弃
                this.cancelTaskBatch(id)
                break;
            case BtnType.BTN_DOCVIEW://文件预览
                this.docPreview({ "taskid": id })
                break;
            case BtnType.BTN_VIEW:
                //window.open("#/main/govern/proinfo?id=" + id + "&type=" + 0)
                window.open("/spa/govern/static/index.html#/main/govern/proinfo?id=" + id + "&type=" + 0)
                break;
            case BtnType.BTN_SHAREBATCH://批量共享，列表按钮
                this.addShare(id);
            case BtnType.BTN_EXTENSION://延期
                this.doExtension(id, modelType)
                break;
            case BtnType.BTN_FINISHUP://办结
                this.doExtension(id, modelType)
                break;
            case BtnType.BTN_INSTRUCT://批示
                this.doInstructions(id)
                break;
            case BtnType.BTN_SCHEDULEVIEW://进度视图
                window.open("/spa/govern/static/index.html#/main/govern/proinfo?id=" + id + "&selectTabKey=1");
                break;
            case BtnType.BTN_EXPORT://导出台账
                this.exportAccount(id)
                break;
            case BtnType.BTN_CREATE://领导点评-批示按钮触发
                this.doInstructions(id)
                break;
            case BtnType.BTN_EDIT://编辑
                this.doEditInstructions(id);
                break;
            case BtnType.BTN_DELETE://删除评论
                this.deleteInstructs(id)
                break;
            case BtnType.BTN_DELETEBATCH://删除共享
                this.delBatchShare(id)
                break;
            case BtnType.BTN_TASKDELETE://删除任务
                this.delTask(id)
                break;
            case BtnType.BTN_TASTREOPEN://重新开启
                this.reopenTask(id)
                break;
            default:
                return false;
        }
    }

    /**
     * 延期、完结申请
     */
    doExtension = (id, actiontype) => {
        Apis.getActionSetting({ "taskid": id, "actiontype": actiontype }).then(data => {
            if (parseInt(data.status) == 1) {
                if (data.isShowModel) {//lusx 19.03.15 无用if逻辑 与后端开发沟通,确认目前不存在弹框形式,
                    if (actiontype == BtnType.BTN_EXTENSION) {
                        message.warning("您需要在后台开启延期设置");
                    }
                    if (actiontype == BtnType.BTN_FINISHUP) {
                        message.warning("您需要在后台开启办结设置");
                    }
                } else {
                    if (data.status == "-1") {
                        message.error(data.error);
                    } else {
                         window.open("/spa/workflow/index_form.jsp#/main/workflow/req?requestid=" + data.newrequestid + "&workflowid=" + data.flowid + "&taskid=" + id + "&actiontype=" + actiontype);
                       // window.open("/spa/workflow/index_form.jsp#/main/workflow/req?iscreate=1&" + data.workflowid);
                    }
					window.location.reload();
                }
            } else {
                message.error(data.error);
            }
        }).catch(error => {
            message.error(error);
        });
    }

    /**
     * 批示
     */
    doInstructions = (id) => {
        let params = { 'content': this.content, 'instype': 1, 'taskId': id }
        Apis.saveInstruct(params).then(result => {
            if (result.status == "1") {
                message.destroy();
                message.success(getLabel('83885', "操作成功！"));
            } else if (data.status == -3) {
                message.warning(data.error)
                return;
            } else {
                message.destroy();
                message.error(getLabel('384535', "提交失败！"));
                return;
            }
        });
        this.handleShareDialog(false);
    }

    //批量共享
    addShare = (valus) => {
        Apis.addShare({ id: this.id, ids: this.ids.join(","), ...valus }).then(data => {
            if (parseInt(data.status) == 1) {
                if (data.status == "1") {
                    this.shareStore.onShowAdd(false);
                    message.success(getLabel('119,15242', "共享成功"));
                } else {
                    message.error(getLabel(119, "共享") + getLabel(32140, "异常，请联系管理员!"));
                }
            } else {
                message.error(data.error);
            }
        }).catch(error => {
            message.error(error);
        })
    }

    //废弃
    cancelTask(id) {
        Apis.cancelTask({ taskid: id }).then(data => {
            if (parseInt(data.status) == 1) {
                this.isDiscard = true;
                message.success(`${getLabel('383313', '废弃成功')}`);
                window.location.reload();
            } else {
                message.error(data.error);
            }
        }).catch(error => {
            message.error(error);
        });
    }

    //批量废弃
    cancelTaskBatch(id) {
        Apis.cancelTask({ taskids: id.join(",") }).then(data => {
            if (parseInt(data.status) == 1) {
                message.success(`${getLabel('201,84565', '取消成功！')}`);
            } else {
                message.error(data.error);
            }
        }).catch(error => {
            message.error(error);
        });
    }

    //完结
    @action
    finishTask(id, props) {
        Apis.finishTask({ taskid: id }).then(data => {
            if (parseInt(data.status) == 1) {
                this.isFinishTask = true;
                this.getNewRightMenu(id);
                message.success(`${getLabel('16634,84565', '确认成功！')}`);
                window.location.reload();
            } else {
                message.error(data.error);
            }
        }).catch(error => {
            message.error(error);
        });
    }
    //获取详情页右侧按钮组新的rightMenu
    @action
    getNewRightMenu(props, id) {
        let params = { "id": id }
        Apis.getProInfo(params).then(data => {
            if (parseInt(data.status) == 1) {
                let { title = "", columns = [], rightMenu = {}, quickBtn = {}, isRight, shareLevel, supervise1, supervise2 } = data;
                props.loaded = true;
                props.isRight = isRight;
                props.shareLevel = shareLevel;
                props.supervise1 = supervise1;
                props.supervise2 = supervise2;
                props.status.maininfoTitle = title;
                props.status.columns = columns;
                props.status.rightMenu = rightMenu;
                props.status.quickBtn = quickBtn;
                props.status.loading = false;
                props.status.selectTabKey = "0";
            } else {
                message.error(data.error);
            }
        }).catch(error => {
            message.error(error);
        });
    }

    /**
     * 签收任务
     */
    signingTask(id, callBack, _this) {
        Apis.signingTask({ taskid: id }).then(data => {
            if (data.status === "1") {
                message.success(`${getLabel('501355', '已签收任务')}`);
                if (typeof callBack === 'function') {
                    callBack(_this);
                }
            }
        })
    }

    /**
     * 关注任务
     */
    attentTask(id, callBack, _this) {
        Apis.attentTask({ id }).then(data => {
            if (parseInt(data.status) == 1) {
                message.success(`${getLabel('25436,84565', '关注成功')}`);
                if (typeof callBack === 'function') {
                    callBack(_this);
                }
            } else {
                message.error(data.error);
            }
        }).catch(error => {
            message.error(error);
        });
    }

    /**
     * 取消关注任务
     */
    disAttentTask(id, callBack, _this) {
        Apis.disAttentTask({ id }).then(data => {
            if (parseInt(data.status) == 1) {
                message.success(`${getLabel('385762', '已取消关注')}`);
                if (typeof callBack === 'function') {
                    callBack(_this);
                }
            } else {
                message.error(data.error);
            }
        }).catch(error => {
            message.error(error);
        });
    }

    exportAccount(id) {
        let taskids = id.join(",");
        let url = "/api/govern/task/exportProAccountExcel?taskids=" + taskids;
        window.location.href = url;
    }

    /**
     * 编辑批示
     */
    doEditInstructions = (id) => {
        let params = { 'content': this.content, 'instype': 1, 'taskId': id, 'id': this.id }
        Apis.saveInstruct(params).then(result => {
            if (result.status == "1") {
                message.destroy();
                message.success(getLabel('83885', "操作成功！"));
            } else if (data.status == -3) {
                message.warning(data.error)
                return;
            } else {
                message.destroy();
                message.error(getLabel('384535', "提交失败！"));
                return;
            }
        });
        this.handleShareDialog(false);
    }

    //删除评论
    @action
    deleteInstructs(id) {
        this.loading = true;
        Apis.deleteInstruct({ id }).then(data => {
            if (parseInt(data.status) == 1 || data.status == true) {
                message.success(`${getLabel('83472', '删除成功！')}`);
            } else if (data.status == -2) {
                message.warning(data.error);
            } else {
                message.error(data.error);
            }
            this.loading = false;
        }).catch(error => {
            message.error(error);
        });
    }

    //删除评论
    @action
    delBatchShare(value) {
        this.loading = true;
        Apis.delBatchShare({ selectedId: value, id: this.id }).then(data => {
            if (parseInt(data.status) == 1) {
                message.success(`${getLabel('83472', '删除成功！')}`);
            } else {
                message.error(data.error);
            }
            this.loading = false;
        }).catch(error => {
            message.error(error);
        });
    }


    //删除任务
    @action
    delTask(value) {
        this.loading = true;
        Apis.deleteTask({ "taskid": value }).then(data => {
            if (parseInt(data.status) == 1) {
                message.success(`${getLabel('83472', '删除成功！')}`);
                if (this.deletclose) {

                    window.close();
                } else {
                    window.location.reload();
                }

            } else {
                message.error(data.error);
            }
            this.loading = false;
        }).catch(error => {
            message.error(error);
        });
    }

    //重新开启任务
    @action
    reopenTask(value) {
        this.loading = true;
        Apis.reopenTask({ "taskid": value }).then(data => {
            if (parseInt(data.status) == 1) {
                message.success(`${getLabel('508139', '重启成功！')}`, 3);
                window.location.reload();
            }
            if (data.status == '-1') {
                message.error(data.error);
            }
            if (data.status == '-2') {
                message.warning(`${getLabel(2012, "对不起，您暂时没有权限！")}`)
            }
            this.loading = false;
        }).catch(error => {
            message.error(error);
        });
    }

    /**
      * 校验真正的form
      */
    checkValidate = () => {
        let _this = this;
        return new Promise(function (resolve, reject) {
            _this.arrayValid = [];
            _this.filedsize = 0;
            let _index = 0;
            _this.listStoreB["condition"].map((c) => {//#587348 概述：E9，督办，立项，删除一个必填项为空的子任务后，点击保存，没反应
                _this.filedsize = _this.filedsize + c.items.length;
                c.items.map((item, index) => {
                    _this.formB.validate(item.domkey[0]).then(({ isValid }) => {//这是个异步的
                        _index = _index + 1;
                        _this.arrayValid.push(isValid);
                        if (_index == _this.filedsize) {
                            resolve(_this.arrayValid);
                        }
                    })
                })
            })
        })

    }

    @action
    getCardStorefun = (store) => {
        this.Card = store;
    }

    cutoffTime = (params) => {
        for (let key in params) {
            let value = params[key];
            if ((key == 'astarttime' || key == 'aendtime' || key == 'starttime' || key == 'endtime') && value.length > 5) {
                params[key] = value.substring(0, 5);
            }
        }
    }
}
